package com.sphd.beautysalon.presenter;


import android.content.DialogInterface;

import com.android.volley.VolleyError;
import com.sphd.beautysalon.info.SortInfo;
import com.sphd.beautysalon.model.FoodTypeModelImpl;
import com.sphd.beautysalon.view.FoodTypeView;

import java.util.List;

/**
* Created by Hu on 2016/11/14
*/

public class FoodTypePresenterImpl implements FoodTypePresenter{
    FoodTypeView foodTypeView;
    FoodTypeModelImpl foodTypeModel;
    DialogInterface dialog;
    public FoodTypePresenterImpl(FoodTypeView foodTypeView) {
        this.foodTypeView = foodTypeView;
        foodTypeModel=new FoodTypeModelImpl();
    }

    @Override
    public void addData(String url) {
        foodTypeView.showLoading();
        foodTypeModel.sendUrl(url,this);
    }

    @Override
    public void sendError(VolleyError error) {
        foodTypeView.dissLoading();
    }

    @Override
    public void sendRes(List<SortInfo> sortInfos) {
        foodTypeView.recRes(sortInfos);
        foodTypeView.dissLoading();
    }

    @Override
    public void sendEdit(String s, DialogInterface dialog) {
        this.dialog=dialog;
        foodTypeView.showLoading();
        foodTypeModel.sendEdit(s,this);

    }

    @Override
    public void sendEditRes(int res) {
        foodTypeView.recEditRes(res,dialog);
        foodTypeView.dissLoading();
    }


}